#ifndef PCDUAL_H
#define PCDUAL_H

#include "rknn_api.h"
#include "opencv2/core/mat.hpp"
#include <QObject>
#include <QString>
#include <QVariantMap>
#include <QMutex>

class PCDual : public QObject
{
    Q_OBJECT
public:
    explicit PCDual(QObject *parent = nullptr);
    ~PCDual();

    int loadModel(const QString &modelPath, QVariantMap &modelDetail);
    int unloadModel();
   cv::Mat detect(void *inputA, const QVector<int8_t> &inputB, float &core);

    QString getErrorString() const { return errorString; }  // 获取中文错误信息
    bool canRun;
    rknn_tensor_attr inputAttrs[2];
private:
    // 内部方法
    int queryModelInfo(QVariantMap &modelDetail);
    const char* get_type_string(int type);

    // 成员变量
    rknn_context ctx;
    unsigned char *modelData;

    rknn_tensor_attr outputAttrs[2];
    rknn_tensor_mem *input_mems[2];
    rknn_tensor_mem *output_mems[2];

    size_t modelDataSize;

    rknn_sdk_version version;
    QString errorString;

    QMutex mutex;  // 确保线程安全
};

#endif // PCDUAL_H
